import {reqGetUserAddressListData,reqGetTradeInfoData} from "@/api"
const state={
  userAddressList:[],
  tradeInfo:{}
}
const actions={
  // 1. 获取收件人详细地址列表
  async getUserAddressList() {
    const res = await reqGetUserAddressListData()
    console.log('address',res)
  },

   // 2. 获取trade页面详细内容信息
   async getTradeInfoData({commit}) {
    const res = await reqGetTradeInfoData()
    // console.log('trade',res)
    if (res.code === 200) {
      commit('SAVE_TRADE_INFO_DATA',res.data)
    }
  }
}
const mutations={
  // 1. 存储用户地址列表
  // SAVE_USER_ADDRESS_LIST(state,addressList) {
  //   state.userAddressList = addressList
  // },
  // 2.存储商品信息
  SAVE_TRADE_INFO_DATA(state,payload){
    state.tradeInfo = payload
  }
}
const getters={
  // 1. 待付款的商品列表
  detailArrayList(state) {
    return state.tradeInfo.detailArrayList
  },
  // 2. 原始待付款的商品总金额
  originalTotalAmount(state) {
    return state.tradeInfo.originalTotalAmount
  },
  // 3. 实付总金额
  totalAmount(state) {
    return state.tradeInfo.totalAmount
  },
  // 4. 订单编号
  tradeNo(state) {
    return state.tradeInfo.tradeNo
  },
  // 5. 商品数量
  totalNum(state) {
    return state.tradeInfo.totalNum
  },
  // 6. 当前账号或是商品的返现金额
  activityReduceAmount(state) {
    return state.tradeInfo.activityReduceAmount
  }
}
export default{
  namespaced:true,
  actions,
  state,
  mutations,
  getters
}